<ol class="breadcrumb">
  <li>
    <a class="badge badge-type" href="#">Master</a>
  </li>
  <li class="active">
    <span class="badge badge-type">Slave</span>
    {{slave_id}}
  </li>
</ol>

<div class="alert alert-error hide" id="alert">
  <button class="close" data-dismiss="alert">×</button>
  <strong>{{alert_message}}</strong>
</div>

<div class="row" id="slave">
  <div class="col-md-3">
    <div class="well">
      <dl class="inline clearfix">
        <dt>Cluster:</dt>
        <dd>
          <span ng-show="clusterNamed">{{cluster}}</span>
          <span ng-show="!clusterNamed">
            (Unnamed)
            <i class="icon-info-sign"
              tooltip="To name this cluster, set the --cluster flag when starting the master."
              tooltip-placement="right"></i>
          </span>
        </dd>
        <dt>Slave:</dt>
        <dd>{{state.hostname}}</dd>
        <dt>Version:</dt>
        <dd>{{state.version}}</dd>
        <dt>Built:</dt>
        <dd>
          <m-timestamp value="{{state.build_time * 1000}}"></m-timestamp>
        </dd>
        <dt>Started:</dt>
        <dd>
          <m-timestamp value="{{state.start_time * 1000}}"></m-timestamp>
        </dd>
        <dt>Master:</dt>
        <dd>{{state.master_hostname}}</dd>
      </dl>
      <p><a href="" ng-click="log($event)">LOG</a></p>

      <h4>Tasks</h4>
      <table class="table table-condensed">
        <tbody>
          <tr>
            <td>Staged</td>
            <td class="text-right">{{state.staged_tasks | number}}</td>
          </tr>
          <tr>
            <td>Started</td>
            <td class="text-right">{{state.started_tasks | number}}</td>
          </tr>
          <tr>
            <td>Finished</td>
            <td class="text-right">{{state.finished_tasks | number}}</td>
          </tr>
          <tr>
            <td>Killed</td>
            <td class="text-right">{{state.killed_tasks | number}}</td>
          </tr>
          <tr>
            <td>Failed</td>
            <td class="text-right">{{state.failed_tasks | number}}</td>
          </tr>
          <tr>
            <td>Lost</td>
            <td class="text-right">{{state.lost_tasks | number}}</td>
          </tr>
        </tbody>
      </table>

      <h4>Resources</h4>
      <table class="table table-condensed">
        <thead>
          <tr>
            <td></td>
            <td class="text-right">Used</td>
            <td class="text-right">Allocated</td>
          </tr>
        </thead>
        <tbody>
          <tr>
            <td>CPUs</td>
            <td class="text-right">{{monitor.statistics.cpus_total_usage | number}}</td>
            <td class="text-right">{{state.resources.cpus | number}}</td>
          </tr>
          <tr>
            <td>Memory</td>
            <td class="text-right">{{monitor.statistics.mem_rss_bytes | dataSize}}</td>
            <td class="text-right">
              {{state.resources.mem * (1024 * 1024) | dataSize}}
            </td>
          </tr>
          <tr>
            <td>Disk</td>
            <td class="text-right">{{0 | dataSize}}</td>
            <td class="text-right">
              {{state.resources.disk * (1024 * 1024) | dataSize}}
            </td>
          </tr>
        </tbody>
      </table>
    </div>

  </div>
  <div class="col-md-9">
    <table m-table table-content="slave.frameworks" title="Frameworks"
      class="table table-striped table-bordered table-condensed">
      <thead>
        <tr>
          <th data-key="id">ID</th>
          <th data-key="user">User</th>
          <th data-key="name">Name</th>
          <th data-key="num_tasks">Active Tasks</th>
          <th data-key="cpus">CPUs (Used / Allocated)</th>
          <th data-key="Mem">Mem (Used / Allocated)</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="framework in $data">
          <td>
            <a href="{{'#/slaves/' + slave_id + '/frameworks/' + framework.id}}">
              {{(framework.id | truncateMesosID) || framework.name}}</a>
            <button class="btn btn-xs btn-toggle btn-default"
              clipboard
              data-clipboard-text="{{framework.id}}"
              tooltip="Copy ID"
              tooltip-placement="right"
              tooltip-trigger="clipboardhover">
            </button>
          </td>
          <td>{{framework.user}}</td>
          <td>{{framework.name}}</td>
          <td>{{framework.num_tasks | number}}</td>
          <td>{{monitor.frameworks[framework.id].statistics.cpus_user_usage + monitor.frameworks[framework.id].statistics.cpus_system_usage | number}} / {{framework.cpus | number}}</td>
          <td>{{monitor.frameworks[framework.id].statistics.mem_rss_bytes | dataSize}} / {{framework.mem * (1024 * 1024) | dataSize}}</td>
        </tr>
      </tbody>
    </table>

    <table m-table table-content="slave.completed_frameworks" title="Completed Frameworks"
      class="table table-striped table-bordered table-condensed">
      <thead>
        <tr>
          <th data-key="id">ID</th>
          <th data-key="user">User</th>
          <th data-key="name">Name</th>
          <th data-key="tasks.length">Active Tasks</th>
          <th data-key="resources.cpus">CPUs</th>
          <th data-key="resources.mem">Mem</th>
        </tr>
      </thead>
      <tbody>
        <tr ng-repeat="completed_framework in $data">
          <td>
            <a href="{{'#/slaves/' + slave_id + '/frameworks/' + completed_framework.id}}">
              {{completed_framework.id | truncateMesosID}}</a>
            <button class="btn btn-xs btn-toggle btn-default"
              clipboard
              data-clipboard-text="{{framework.id}}"
              tooltip="Copy ID"
              tooltip-placement="right"
              tooltip-trigger="clipboardhover">
            </button>
          </td>
          <td>{{completed_framework.user}}</td>
          <td>{{completed_framework.name}}</td>
          <td>{{completed_framework.num_tasks | number}}</td>
          <td>{{completed_framework.cpus | number}}</td>
          <td>{{completed_framework.mem * (1024 * 1024) | dataSize}}</td>
        </tr>
      </tbody>
    </table>
  </div>
</div>
